import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wanchong/conf.dart';
import 'package:wanchong/path.dart';

class ImHome extends StatefulWidget {
  @override
  _ImHomeState createState() => _ImHomeState();
}

class _ImHomeState extends State<ImHome> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0.0,
      ),
      body: ListView(
        children: <Widget>[
          _item("在线客服", "查看与客服消息记录", "assets/store/shop_service_icon.png", 0,
              () {}),
          _item("系统通知", "balbalabalabala", "assets/store/shop_service_icon.png",
              8, () {}),
          _item("同城消息", "", "assets/store/shop_service_icon.png", 0, () {
            Navigator.of(context).pushNamed(ImCityPath);
          }),
        ],
      ),
    );
  }

  Widget _item(String title, String desc, String icon, int number, callBack) {
    return GestureDetector(
      onTap: () {
        callBack();
      },
      child: Container(
        width: double.infinity,
        color: Colors.white,
        child: Row(
          children: <Widget>[
            Container(
              margin: EdgeInsets.all(15.0),
              width: 70.0,
              height: 70.0,
              child: Image.asset(
                icon,
                fit: BoxFit.cover,
              ),
            ),
            Expanded(
              child: Column(
                children: <Widget>[
                  SizedBox(
                    height: 15.0,
                  ),
                  Container(
                    // width: double.infinity,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        Container(
                          // color: Colors.amber,
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: <Widget>[
                              Text(title),
                              Text(desc),
                            ],
                          ),
                        ),
                        Row(
                          children: <Widget>[
                            number > 0
                                ? Container(
                                    decoration: BoxDecoration(
                                      color: Colors.red,
                                      borderRadius: BorderRadius.circular(10),
                                    ),
                                    width: 20.0,
                                    height: 20.0,
                                    child: Center(
                                      child: Text(
                                        number.toString(),
                                      ),
                                    ),
                                  )
                                : Container(),
                            Container(
                              child: Icon(Icons.chevron_right),
                              margin: EdgeInsets.only(right: 15.0),
                            ),
                          ],
                        )
                      ],
                    ),
                  ),
                  SizedBox(
                    height: 15.0,
                  ),
                  Divider(
                    color: Color(BorderColor),
                    height: ScreenUtil.getInstance().setHeight(1),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

/*
Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Column(
                        children: <Widget>[
                          Text(title),
                          Text(desc),
                        ],
                      ),
                      Row(
                        children: <Widget>[
                          number > 0
                              ? Container(
                                  decoration: BoxDecoration(
                                    color: Colors.red,
                                    borderRadius: BorderRadius.circular(10),
                                  ),
                                  width: 20.0,
                                  height: 20.0,
                                  child: Center(
                                    child: Text(
                                      number.toString(),
                                    ),
                                  ),
                                )
                              : Container(),
                          Container(
                            child: Icon(Icons.chevron_right),
                            margin: EdgeInsets.only(right: 15.0),
                          ),
                        ],
                      )
                    ],
                  ),
*/
